local UIBase = require("view.UIBase")
local PopupSkillTip = class("PopupSkillTip", UIBase)

function PopupSkillTip:ctor(skillId, callback)
    self._skillId = skillId
    self._callback = callback
    local resource = {
        path = "Prefabs/Popup",
        name = "PopupSkillTip",
        canvas = 3
    }
    PopupSkillTip.super.ctor(self, resource)
end

function PopupSkillTip:start()
    self._panelTouch:SetCallback(handler(self, self._onPanelTouch))
    local skillCfg = require("config.fight_skill").get(self._skillId)
    self._textName.text = skillCfg.name
    self._textDesc.text = skillCfg.desc
    self._skillIcon:updateUI(self._skillId)
end

function PopupSkillTip:_onPanelTouch(state)
    if state == 3 then
        self:close()
    end
end

function PopupSkillTip:onClose()
    if self._callback then
        self._callback()
    end
end

return PopupSkillTip
